﻿using UnityEngine;

namespace JH
{
    public static class PrefabFitLayout
    {
        /// <summary>
        ///  设置rect的本地坐标Z值为0，缩放为1，旋转为0
        ///      UI预制体加载到layout下时，一般需要设置的参数
        /// </summary>
        public static void FitLayoutEm(this RectTransform rect)
        {
            //设置大小和位置
            var localPosition = rect.localPosition;
            localPosition -= new Vector3(0, 0, localPosition.z);
            rect.localPosition = localPosition;
            rect.localScale = Vector3.one;
            rect.rotation =  Quaternion.identity;
        }
    }
}